package com.crm.service.statisticAnalysis.controller;

import com.crm.model.common.dtos.ResponseResult;
import com.crm.service.statisticAnalysis.service.SellService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@RequestMapping("/api/v1/statistics/sell")
@Slf4j
@Api(value = "销售统计")
public class SellController {

    @Autowired
    private SellService sellService;


    @ApiOperation("销售分页查询")
    @GetMapping("/sellPage")
    private ResponseResult sellPage(@RequestParam("page") Integer page,
                                    @RequestParam("pageSize") Integer pageSize,
                                    @RequestParam(value = "department",required = false) String department) {
        log.info("销售分页查询{},{},{}", page, pageSize, department);
        return sellService.sellPage(page, pageSize, department);
    }

    @ApiOperation("折线图")
    @GetMapping("/sell_lineChart")
    private ResponseResult sellLineChart(
            @DateTimeFormat(pattern = "yyyy/MM/dd") LocalDate begin,
            @DateTimeFormat(pattern = "yyyy/MM/dd") LocalDate end) {
        log.info("销售折线图:{}{}",begin,end );
        return sellService.sellLineChart(begin,end);
    }



}
